package com.zyao89.view.zweb.views;

import ohos.agp.components.webengine.WebView;

/**
 * @author Zyao89
 * 2017/11/13.
 */
class FixedOnReceivedTitle {
    private BrowserAgentEx browserAgent;
    private boolean mIsOnReceivedTitle;

    void setBrowserAgentEx(BrowserAgentEx browserAgent) {
        this.browserAgent = browserAgent;
    }

    void onPageStarted() {
        mIsOnReceivedTitle = false;
    }

    void onPageFinished(WebView view) {
        if (!mIsOnReceivedTitle && browserAgent != null) {
//            WebBackForwardList list = null;
//            try
//            {
//                list = view.copyBackForwardList();
//            }
//            catch (NullPointerException e)
//            {
//                ZLog.with(this).w(e.getMessage());
//            }
//            if (list != null && list.getSize() > 0 && list.getCurrentIndex() >= 0 && list.getItemAtIndex(list.getCurrentIndex()) != null)
//            {
//                String previousTitle = list.getItemAtIndex(list.getCurrentIndex()).getTitle();
//                mWebChromeClient.onReceivedTitle(view, previousTitle);
//            }
        }
    }

    void onReceivedTitle() {
        mIsOnReceivedTitle = true;
    }
}
